package com.sharemarking.wa.platform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sharemarking.wa.common.entity.SearchHistory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dxy
 */
@Repository
public interface SearchHistoryMapper extends BaseMapper<SearchHistory> {
    @Select("SELECT key_word FROM wa_search_history WHERE member_Id = #{memberId} GROUP BY key_word LIMIT 20")
    List<String> getMySearchList(Integer memberId);

    @Select("SELECT key_word,COUNT(*) FROM wa_search_history GROUP BY key_word ORDER BY COUNT(*) DESC LIMIT 8")
    List<String> getHotSearchList(Integer memberId);

    @Select("SELECT key_word,COUNT(*) FROM wa_search_history GROUP BY key_word ORDER BY COUNT(*) DESC LIMIT 8")
    List<String> getHotSearchList();

    @Delete("DELETE from wa_search_history where member_Id = #{memberId}")
    void deleteSearch(Integer memberId);
}
